returns a non-reference comparer for this class
Syntax
Visual Basic (Declaration) | |
---|
Public Shadows Shared ReadOnly Comparer As Comparable(Of T) |
Example
Library/Library.Test/TestEquatable.cs
C# | Copy Code |
---|
IComparer<Null<int>> cmp = Null<int>.Comparer;
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;
Assert.IsTrue(cmp.Compare(null, nil) == 0);
Assert.IsTrue(cmp.Compare(nil, null) == 0);
Assert.IsTrue(cmp.Compare(b1, b2) == 0);
Assert.IsTrue(cmp.Compare(a, b1) < 0);
Assert.IsTrue(cmp.Compare(b1, a) > 0);
Assert.IsTrue(cmp.Compare(nil, a) < 0);
Assert.IsTrue(cmp.Compare(a, nil) > 0);
Assert.IsTrue(cmp.Compare(null, a) < 0);
Assert.IsTrue(cmp.Compare(a, null) > 0); |
VB.NET | Copy Code |
---|
Dim cmp As IComparer(Of Null(Of Integer)) = Null(Of Integer).Comparer
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6
Assert.IsTrue(cmp.Compare(Nothing, nil) = 0)
Assert.IsTrue(cmp.Compare(nil, Nothing) = 0)
Assert.IsTrue(cmp.Compare(b1, b2) = 0)
Assert.IsTrue(cmp.Compare(a, b1) < 0)
Assert.IsTrue(cmp.Compare(b1, a) > 0)
Assert.IsTrue(cmp.Compare(nil, a) < 0)
Assert.IsTrue(cmp.Compare(a, nil) > 0)
Assert.IsTrue(cmp.Compare(Nothing, a) < 0)
Assert.IsTrue(cmp.Compare(a, Nothing) > 0) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also